package com.keekus.common.dto;

import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.Date;

public class BaseDTO implements Serializable{

	private String	createdBy;

	private Date	createdDate;

	private String	updatedBy;

	private Date	updatedDate;

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy == null ? null : createdBy.toLowerCase();
	}

	public String getUpdatedBy() {
		return updatedBy;
	}

	public void setUpdatedBy(String updatedBy) {
		this.updatedBy = updatedBy == null ? null : updatedBy.toLowerCase();
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public Date getUpdatedDate() {
		return updatedDate;
	}

	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		try{
			Class c = this.getClass();
			Field [] fields = c.getDeclaredFields();
			sb.append(c).append("{");
			for(int i = 0; i < fields.length; i++) {
				Field f = fields[i];
				f.setAccessible(true);
				sb.append(f.getName()).append(":");
				if(f.getType() == Integer.class) {
					sb.append(f.getInt(this));
				}else if(f.getType() == Long.class) {
					sb.append(f.getLong(this));
				}else if(f.getType() == char.class) {
					sb.append(f.getChar(this));
				}else if(f.getType() == Double.class) {
					sb.append(f.getDouble(this));
				}else if(f.getType() == Float.class) {
					sb.append(f.getFloat(this));
				}else{
					sb.append(f.get(this));
				}
				sb.append(",");
			}
			sb.append("}");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return sb.toString();
	}

}